<?php
////////////////////////////////////////////////////
//	LinBoard
//	Framework/Misc.php
//	Created: 22th February 2009; 01:23 UTC
//	LinBoard (c) Copyright OpenInferno 2008, 2009
////////////////////////////////////////////////////

//Setup Environment
error_reporting(E_ALL | E_STRICT);

//Direct Access Check
if(!defined("LINBOARD"))
{
	die("<h1>Access Error</h1>Direct Access to this script is forbidden.");
}

class Misc
{
	public function cleanUsername($username)
	{
		Framework::Mysql()->requireConnection();
		
		return strtolower(trim(Framework::Mysql()->escapeString(htmlentities($username))));
	}
	
	public function stylePost($content)
	{
		//Parse @Username stuff. Twitter-like.
		$content = preg_replace("/\@(.*?) /", "<a href=\"".Framework::Config()->Main['weburl']."/profile.php?user=$1\">@$1</a> ", $content);
		
		return $content;
	}
	
	public function generateNavigation()
	{
		//TODO!
	}
	
	public static function getInstance()
	{
		static $instance;
		if(!isset($instance))
		{
			$class = __CLASS__;
			$instance = new $class;
		}
		return $instance;
	}
	
}

?>